package com.ssm.gbq.dao.impl;

import com.ssm.gbq.dao.DoctorCategoryDao;
import com.ssm.gbq.mapper.DoctorCategoryMapper;
import com.ssm.gbq.model.DoctorCategory;
import gbq.ssm.utils.PageBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class DoctorCategoryDaoImpl implements DoctorCategoryDao {
    @Autowired
    private DoctorCategoryMapper doctorCategoryMapper;

    public PageBounds<DoctorCategory> openDoctorCategoryTable(String name, int currentPage, int pageSize) throws Exception {
        final int totalSize = doctorCategoryMapper.countByExample(name);
        PageBounds<DoctorCategory> pageBounds = new PageBounds<DoctorCategory>(currentPage, totalSize, pageSize);
        List<DoctorCategory> list = doctorCategoryMapper.selectByLimitPage(name, pageBounds.getOffset(), pageBounds.getPageSize());
        pageBounds.setPageList(list);
        return pageBounds;
    }

    public List<DoctorCategory> selectAllDoctorCategory() {
        return doctorCategoryMapper.selectAllDoctorCategory();
    }

    public void deleteDoctorCategoryByIds(List<Integer> ids) throws Exception {
        doctorCategoryMapper.deleteByPrimaryKey(ids);
    }
    public int deleteDoctorCategoryById(Integer id) {
        return doctorCategoryMapper.deleteDoctorCategoryById(id);
    }

    public int addDoctorCategory(DoctorCategory doctorCategory) throws Exception {
        return doctorCategoryMapper.addDoctorCategory(doctorCategory);
    }

    public int updateDoctorCategory(DoctorCategory doctorCategory) {
        return doctorCategoryMapper.updateDoctorCategory(doctorCategory);
    }
}
